<template>
	<view class="content">
		<view class="head-wrap">
			<view class="head-title-wrap">
				<view>
					<text style="margin-right: 20rpx;">方案名称: {{inform.hvo.pk_wa_class.name}}</text>
				</view>				<view>
					<text style="margin-right: 20rpx;">上报科室: {{dept?dept:''}}</text>
					<text>|</text>
					<text style="margin-left: 20rpx;">提交人: {{meritsInform.data.hvo.creator.name}}</text>
				</view>
				<view>
					<text style="margin-right: 20rpx;">薪资期间: {{meritsDate}}</text>
				</view>
				<view>
					<text style="margin-right: 20rpx;">提交时间:{{meritsInform.data.hvo.ts}}</text>
				</view>			</view>
			<view class="prograss" @click="checkPrograss">审核进度</view>
			
		</view>
		<view class="show-detail">
			<view class="show-detail-sub" v-for="(value,key) in inform.itemcount" :key="key">
				<view class="show-detail-box">{{value}}</view>
				<view class="show-detail-title">{{key}}</view>
			</view>
		</view>
		<view v-for="(item,index) in inform.bvos" :key="index" class="person-sub">
			<view class="top">
				<text>{{item.psnname?item.psnname:''}}({{item.psncode?item.psncode:''}})</text>
				<view style="margin-top: 4px;">{{item.deptname?item.deptname:''}}</view>
			</view>
			<view class="main" >
				<view style="display: flex;" v-for="(value,key) in item.merits" :key="key">
					<view style="width: 130rpx;">{{key}}</view>
					<view >{{value}}</view>
				</view>
			</view>
		</view>
		
		<view class="all-totals">
			<view class="all-totals-des" v-if="false">
				<text>总计:</text>
				<text style="margin-left: 10rpx;">{{meritsInform.data.hvo.def2}}</text>
			</view>
			<view class="btn-wrap">
				<view class="cancel-exa" @click="cancelExamine" v-if="$store.state.isShowExa==1&&isShowBtn!=1">取消审批</view>
			</view>
			<view class="btn-wrap" v-if="$store.state.isShowExa==1&&isShowBtn==1">
				<view class="adot-btn" @click="exit">驳回</view>
				<view class="confirm-btn" @click="adopt">通过</view>
			</view>
			<assign-module billtype="WAMP"
							@finishExamine="finishService" 
							:formPk="pk" 
							ref="assignCharacter" >
			</assign-module>
		</view>
	</view>
</template>

<script>
	import service from '../../../common/service/new_file.js';
	import apiData from '../../../common/utils/apiData.js';
	import utils from '../../../common/utils/utils.js';
	export default {
		data() {
			return {
				inform:[],
				pk:'',
				dept:'',
				meritsDate:'',
				meritsInform:{},
				examineStatus:'',//审批的状态
				isShowBtn:'',
				isExa:0
			};
		},
		methods:{
			adopt(){
				//通过
				this.$refs.assignCharacter.init('1')
			},
			goback(){
				//返回页面
				uni.navigateTo({
					url:"../meritsExamine/meritsExamine"
				})
			},
			finishService(){
				this.goback()
			},
			exit(obj) {
				this.$refs.assignCharacter.init('2')
			},
			cancelExamine(){
				this.exitExa(this.pk)
			},
			exitExa(pk) {
				let _this = this;
				let data = apiData.setExitExamineData(pk, 'WAMP'); //FN(billtype, isAdopt,pk)
				service.common(data, {
					success: function(res) {
						uni.showToast({
							icon:'none',
							title: '已撤回,即将退出该页面'
						});
						setTimeout(() => {
							uni.navigateTo({
								url:"../meritsExamine/meritsExamine"
							})
						}, 1500);
					},
					fail: function(err) {},
					all: function(all) {}
				});
			},
			checkPrograss(){
				//url: './attendacePrograss?pk=' + this.pk+'&billtype=WAMP'
				uni.navigateTo({
					url:"../../attendance/attendacePrograss?pk=" + this.pk+'&billtype=WAMP'
				});
			},
		},
		onLoad(object) {
			this.isExa = object.isExa
			let myObj = JSON.parse(object.item)
			this.inform = JSON.parse(object.item).data
			this.inform.bvos.forEach(item=>{
				let merits = {}
				let notStr = ['deptname','psncode','psnname']
				for (let key in item) {
					if(notStr.indexOf(key)==-1){
						merits[key] = item[key]
					}
				}
				item.merits = merits
			})
			console.log(this.inform.bvos,'this.inform.bvos')
			this.isShowBtn = object.isShowBtn
			this.meritsInform = myObj
			this.pk = object.pk
			this.dept = myObj.data.hvo.pk_dept.name
			this.meritsDate = myObj.data.hvo.pk_period
		}
	}
</script>

<style lang="scss">
	.cancel-exa{
		display: flex;
		align-items: center;
		justify-content: center;
		flex: 1;
		
		background: #d52b2e;
	}
	.all-totals {
		width: 100%;
		position: fixed;
		display: flex;
		flex-direction: column;
		font-weight: 400;
		font-size: 34rpx;
		color: #FFFFFF;
		bottom: 0;
		.all-totals-des{
			display: flex;
			align-items: center;
			width: 100%;
			height: 80rpx;
			padding: 0 24rpx;
			background: #0dd65e;
		}
		.btn-wrap{
			width: 100%;
			display: flex;
			height: 80rpx;
			.adot-btn{
				display: flex;
				align-items: center;
				justify-content: center;
				flex: 1;
				background: #818181;
			}
			.confirm-btn{
				display: flex;
				align-items: center;
				justify-content: center;
				flex: 1;
				background: #2282ff;
			}
		}
	}
	.show-detail{
		background: #7bb0ff;
		padding: 20rpx 32rpx;
		color: #fff;
		display: flex;
		justify-content: space-between;
		.show-detail-sub{
			width: 33%;
			display: flex;
			flex-direction: column;
			align-items: center;
			justify-content: center;
			.show-detail-box{
				font-size: 34rpx;
				font-weight: 600;
			}
			.show-detail-title{
				font-size: 26rpx;
			}
		}
	}
	.head-title-wrap{
		color: #000000;
		font-weight: 600;
		font-size: 26rpx;
	}
	.head-wrap{
		padding: 20rpx 32rpx;
		display: flex;
		align-items: center;
		color: #0051FF;
		background: #fff;
		justify-content: space-between;
	}
	.content{
		width: 100%;
		padding-bottom: 120rpx;
	}
	.person-sub{
		display: flex;
		align-items: center;
		padding: 20rpx 32rpx;
		margin-bottom: 2rpx;
		background: #ffffff;
		justify-content: space-between;
		.top{
			font-size: 28rpx;
		}
		.main{
			width: 300rpx;
			font-size: 30rpx;
		}
	}
</style>
